package com.dawan.sbjy.test;

public class MyThread extends Thread{
    public MyThread(String name) {
        super(name);
    }
    public void run() {
        for (int i = 0; i < 5; i++) {
            System.out.println(getName() + "  " + i);
        }
    }
    public static void main(String[] args) throws InterruptedException {
        // 启动子进程
        new MyThread("new thread").start();
        for (int i = 0; i < 10; i++) {
            if (i == 5) {
                MyThread th = new MyThread("joined thread");
                th.start();
                th.join();
            }
            System.out.println(Thread.currentThread().getName() + "  " + i);
        }
    }
}
